import telebot
import os

# Bot Token
TOKEN = '7702930752:AAGYV0-kGJgMTavSPKxqdgo8tkR_gdthYJI'
bot = telebot.TeleBot(TOKEN)

def save_file(save_dir, file_id, filename=None):
    # 获取文件信息
    file_info = bot.get_file(file_id)
    downloaded_file = bot.download_file(file_info.file_path)
    if not filename:
        filename = os.path.basename(file_info.file_path)
    save_path = os.path.join(save_dir, filename)
    with open(save_path, 'wb') as f:
        f.write(downloaded_file)
    print(f"✅ 已保存文件: {save_path}")
    return save_path